#!/bin/bash
REPO="https://github.com/gincoin-dev/gincoin-core.git"
SRC="/tmp/src"
BUILD="/build"
OPTIONS="$@"

git clone ${REPO} ${SRC} && cd ${SRC}

./autogen.sh && ./configure ${OPTIONS} && make

if [[ ! -f ${SRC}/src/lincoind ]]; then
    echo "Build failed"
    exit 1
fi

test -e ${SRC}/src/lincoind && cp ${SRC}/src/lincoind ${BUILD}/
test -e ${SRC}/src/lincoin-cli && cp ${SRC}/src/lincoin-cli ${BUILD}/
test -e ${SRC}/src/lincoin-tx && cp ${SRC}/src/lincoin-tx ${BUILD}/
test -e ${SRC}/src/qt/lincoin-qt && cp ${SRC}/src/qt/lincoin-qt ${BUILD}/